package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.AuthorsMapper;
import com.qf.pojo.Authors;
import com.qf.service.IAuthorsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AuthorsServiceImpl implements IAuthorsService {

    private AuthorsMapper authorsMapper;
    @Autowired
    public void setAuthorsMapper(AuthorsMapper authorsMapper) {
        this.authorsMapper = authorsMapper;
    }

    @Override
    public Authors find(Long id) {

        Authors authors = authorsMapper.find(id);

        return authors;
    }

    @Override
    public PageInfo<Authors> findAllByName(String authorname, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Authors> allByName = authorsMapper.findAllByName(authorname);

        PageInfo pageInfo=new PageInfo(allByName);
        return pageInfo;

    }

    @Override
    public void updateAuthors(Authors authors) {
        authorsMapper.updateAuthors(authors);
    }

    @Override
    public void addAuthors(Authors authors) {
        authorsMapper.addAuthors(authors);
    }
}
